-
Notifications
You must be signed in to change notification settings - Fork 35
Devin Fledermaus #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Devin Fledermaus #44
Conversation
app.ts
Outdated
| const prevButton: any = document.querySelector("#prev"); | ||
| const clear = ""; | ||
| let paramOne: any = "0" | ||
| let paramTwo: any = "9" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think rather calculate this value based on the size of the window than have a fixed value. Screen sizes change and you can potentially fit more records on the screen. Try to fit as much readable records on the screen as possible.
anzelIMQS
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before I actually review the code, please add semicolons at the end of each line. You have a lot of them missing.
anzelIMQS
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function restructuring to remove the global parameters. These values should be passed around. Functions should not have to know about stuff happening outside of their scope.
app.ts
Outdated
| let currentStats = "Showing results from " + paramOne + " to " + paramTwo + " out of " + count + " results."; | ||
| pageStats.innerHTML = currentStats; | ||
| }); | ||
| } catch (error) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the above comment on the catch
app.ts
Outdated
| } catch (error) { | ||
| console.log(error); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant, a catch on the then of the Promise.
e.g. then( () => {...}).catch( (error) => {})
Not a seperate try and catch block.
app.ts
Outdated
| } catch (error) { | ||
| console.log(error); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the above comment on the catch
app.ts
Outdated
| .then((data) => { | ||
| data = JSON.parse(data); | ||
| let count = data; | ||
| let currentStats = "Showing results from " + paramOne + " to " + paramTwo + " out of " + count + " results."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather use Template Literals. ${}
app.ts
Outdated
| data = JSON.parse(data); | ||
| let count = data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not necessary to do this over 2 lines.
let count = JSON.parse(data);
app.ts
Outdated
| } | ||
| }; | ||
|
|
||
| prev = prevDebounce(prev, 500); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same vibe as the above next
app.ts
Outdated
| getTable(); | ||
| }; | ||
|
|
||
| idJump = debounce(idJump, 500); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same vibe as the above next.
app.ts
Outdated
| }; | ||
| }; | ||
|
|
||
| let next = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The paramOne and paramTwo should be accepted as parameters to this function.
app.ts
Outdated
| }; | ||
| }; | ||
|
|
||
| let prev = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as mentioned in the next.
app.ts
Outdated
| paramTwo = 999999; | ||
| paramOne = paramTwo - getNoOfRows(); | ||
| } else { | ||
| paramOne; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove redundancy.
app.ts
Outdated
| let toParameter: number; | ||
| const height = window.innerHeight; | ||
|
|
||
| let noOfRows = Math.floor(height / 40); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if you rather call the method getNoOfRows which you created, instead of repeating the calculation here. This will also mean you won't need the variable height.
anzelIMQS
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more changes regarding functions.
app.ts
Outdated
| } else { | ||
| //pass | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean. You can completely remove this else since is does nothing.
app.ts
Outdated
|
|
||
| // Displays The Current Results Being Shown | ||
|
|
||
| const stats = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean by recordCount is constant is that you don't have to make an API call every time you call stats since the value is going to be the same for each call.
In this case, I recommend you create a global const variable that you assign the recordCount API response once on the initial load of your program. At the moment it is a hardcoded value. Let the backend determine it.
app.ts
Outdated
| getParameters((fromParameter = 0)); | ||
| }) | ||
| .catch((error) => { | ||
| console.log("Call Hector", error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who's Hector?
app.ts
Outdated
| clearTable(); | ||
| getTable(); | ||
| stats(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can definitely see these 3 functions actually being in one as it always goes together logically. They are always repeated in that order and are not too complex to be split up. It can be all together in getTable()?
app.ts
Outdated
| //// Debounce | ||
|
|
||
| const debounce = (fn: any, delay: number) => { | ||
| let timer: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might need to add timer as a global variable. It's something I noticed with Ashton as well and he got it to work. At this stage, timer is only in the scope of this function.
anzelIMQS
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More cleaning up, please.
app.ts
Outdated
| let end = fromParameter + getNoOfRows(); | ||
| let toParameter: number; | ||
|
|
||
| if (end > 999999) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use 999999. You have recordCount for the max..
app.ts
Outdated
| // getRecordCount(); | ||
| // getHeadings(); | ||
| // getTable(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove clutter.
app.ts
Outdated
| let next = () => { | ||
| let toParameter = getParameters(fromParameter); | ||
|
|
||
| if (toParameter === 999999) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same vibe for recordCount
app.ts
Outdated
| if (end > 999999) { | ||
| toParameter = 999999; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same vibe for recordCount
app.ts
Outdated
| console.log("CALL HECTOR!!!"); | ||
| }; | ||
|
|
||
| const getParameters = (fromParameter: number) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add return type
app.ts
Outdated
| return toParameter; | ||
| }; | ||
|
|
||
| const getNoOfRows = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add return type
app.ts
Outdated
| fromParameter = intOne; | ||
| } | ||
|
|
||
| toParameter = fromParameter + getNoOfRows(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still necessary? toParameter isn't used after this?
app.ts
Outdated
| if (search !== NaN && search !== "" && search < 1000000 && search >= 0) { | ||
| if (end > 999999) { | ||
| toParameter = 999999; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same vibe for recordCount.
app.ts
Outdated
| for (let i = 0; i < headingData.length; i++) { | ||
| createHeadingRow(headingData[i]); | ||
| } | ||
| getParameters((fromParameter = 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this necessary? getParameters returns your toParameter but you do nothing with the return result since you don't need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please convert all spaces to tabs. Please change the functions that you defined as variables to be defined as normal functions, you can leave the ones that you actually override as they were.
I made a comment about removing the empty line between the comment and the variable, there are a few places that this should happen.
Its a bit hard to review as it is, please make the changes where ever you think they are relevant and then I will review again.
app.ts
Outdated
| // Heading Row | ||
|
|
||
| const createHeadingRow = (headingData: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather remove the empty line between the variable and the comment.
app.ts
Outdated
| // Heading Row | ||
|
|
||
| const createHeadingRow = (headingData: string) => { | ||
| const heading: any = document.querySelector("#heading"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only place you can have an any in the project is when handling data that comes from the back-end. And even then you can actually use the real type instead of any.
app.ts
Outdated
| // Heading Row (Getting the columns data) | ||
|
|
||
| const getHeadings = () => { | ||
| fetch("http://localhost:2050/columns", { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should put a return in front of the fetch, that would allow other functions to wait on this function.
app.ts
Outdated
| for (let i = 0; i < headingData.length; i++) { | ||
| createHeadingRow(headingData[i]); | ||
| } | ||
| getParameters((fromParameter = 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To many braces and I would rather have this as two lines, where you explicitly call getParamter with a hard coded 0
app.ts
Outdated
| method: "GET", | ||
| headers: { "Content-Type": "application/json" }, | ||
| }) | ||
| .then((res) => res.text()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should check for an error in res here. And you either want to remove the () around the res or specify the type, because currently the compiler thinks the type is any
app.ts
Outdated
| } | ||
| getParameters((fromParameter = 0)); | ||
| }) | ||
| .catch((error) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want to remove the () around the error or specify the type, as currently the compiler thinks the type is any
FritzOnFire
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change your spaces to tabs
app.ts
Outdated
|
|
||
| // Loads all intial fields/data | ||
|
|
||
| window.onload = function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump
app.ts
Outdated
| .then(() => { | ||
| return getTable(); | ||
| }); | ||
| console.log("CALL HECTOR!!!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray console log.
app.ts
Outdated
| console.log("CALL HECTOR!!!"); | ||
| }; | ||
|
|
||
| function getParameters(fromParameter: number) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a return type
app.ts
Outdated
| } | ||
|
|
||
| // Table Content | ||
| function createTableContent(contentData: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They way you are using contentData gives me the idea that it is not simply a string -_-
app.ts
Outdated
| const content: HTMLElement | null = document.getElementById("content"); | ||
|
|
||
| let table = `<div id="row-${contentData[0]}" class="rows"></div>`; | ||
| if (content !== null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to stop the function at this point, and tell the user something is wrong, as the rest of this function is dependent on this having a value.
app.ts
Outdated
| toParameter = maxRecordsID; | ||
| fromParameter = toParameter - getNoOfRows(); | ||
| } else { | ||
| toParameter = fromParameter + getNoOfRows(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this line?
app.ts
Outdated
| getTable(); | ||
| } | ||
|
|
||
| window.addEventListener("resize", debounce(resizing, 500)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should not be in global space.
app.ts
Outdated
| { | ||
| let nextCount = 0; | ||
| const nextButton: HTMLElement | null = document.getElementById("next"); | ||
|
|
||
| const nextDebounce = (fn: any, delay: number) => { | ||
| return function () { | ||
| nextCount++; | ||
| clearTimeout(timer); | ||
| timer = setTimeout(() => { | ||
| fn(); | ||
| }, delay); | ||
| }; | ||
| }; | ||
|
|
||
| let next = () => { | ||
| let toParameter = getParameters(fromParameter); | ||
| let maxRecordsID = recordCount - 1; | ||
|
|
||
| if (toParameter === maxRecordsID) { | ||
| alert("You have reached the final page"); | ||
| } | ||
|
|
||
| let nextAmount = toParameter - fromParameter + 1; | ||
| let nextCountAmount = nextAmount * nextCount; | ||
| fromParameter = fromParameter + nextCountAmount; | ||
| toParameter = fromParameter + getNoOfRows(); | ||
|
|
||
| let end = fromParameter + getNoOfRows(); | ||
|
|
||
| if (end > maxRecordsID) { | ||
| toParameter = maxRecordsID; | ||
| fromParameter = toParameter - getNoOfRows(); | ||
| } | ||
|
|
||
| nextCount = 0; | ||
|
|
||
| getTable(); | ||
| }; | ||
|
|
||
| if (nextButton !== null) { | ||
| nextButton.addEventListener("click", nextDebounce(next, 500)); | ||
| } | ||
| } | ||
|
|
||
| // Previous | ||
| { | ||
| let prevCount = 0; | ||
| const prevButton: HTMLElement | null = document.getElementById("prev"); | ||
|
|
||
| const prevDebounce = (fn: any, delay: number) => { | ||
| return function () { | ||
| prevCount++; | ||
| clearTimeout(timer); | ||
| timer = setTimeout(() => { | ||
| fn(); | ||
| }, delay); | ||
| }; | ||
| }; | ||
|
|
||
| let prev = () => { | ||
| let toParameter = getParameters(fromParameter); | ||
|
|
||
| if (fromParameter === 0) { | ||
| alert("You Are On The First Page"); | ||
| } else { | ||
| let prevAmount = toParameter - fromParameter + 1; | ||
| let prevCountAmount = prevAmount * prevCount; | ||
|
|
||
| let intOne = fromParameter - prevCountAmount; | ||
|
|
||
| if (intOne < 0) { | ||
| fromParameter = 0; | ||
| } else { | ||
| fromParameter = intOne; | ||
| } | ||
|
|
||
| prevCount = 0; | ||
|
|
||
| getTable(); | ||
| } | ||
| }; | ||
|
|
||
| if (prevButton !== null) { | ||
| prevButton.addEventListener("click", prevDebounce(prev, 500)); | ||
| } | ||
| } | ||
|
|
||
| // ID Jump | ||
| { | ||
| const input: any = document.querySelector("input"); | ||
|
|
||
| let idJump = () => { | ||
| let toParameter = getParameters(fromParameter); | ||
| let currentID = fromParameter; | ||
| let search = input.value; | ||
| let end = parseInt(search) + getNoOfRows(); | ||
| let maxRecordsID = recordCount - 1; | ||
|
|
||
| if (search !== NaN && search !== "" && search <= maxRecordsID && search >= 0) { | ||
| if (end > maxRecordsID) { | ||
| toParameter = maxRecordsID; | ||
| fromParameter = toParameter - getNoOfRows(); | ||
| } else { | ||
| fromParameter = parseInt(search); | ||
| toParameter = fromParameter + getNoOfRows(); | ||
| } | ||
| } else if (search !== "") { | ||
| alert("Make Sure Your Desired ID Is Not A Negative Number Or Doesn't Exceed 999999"); | ||
| fromParameter = currentID; | ||
| toParameter = fromParameter + getNoOfRows(); | ||
| input.value = ""; | ||
| } | ||
|
|
||
| getTable(); | ||
| }; | ||
|
|
||
| window.addEventListener("input", debounce(idJump, 500)); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a lot of logic living in global space, either move it to a class, or execute it somewhere else.
index.html
Outdated
| <title>Onboarding JavaScript Task</title> | ||
| <script type="text/javascript" charset="utf-8" src="third_party/jquery-2.0.3.min.js"></script> | ||
| <link rel="stylesheet" href="style.css" /> | ||
| <script src="app.js" defer></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You really should not be using defer in the project, but there are no rules against it, so I'm not going to ask you to remove it.
| button { | ||
| border: none; | ||
| padding: 5px 10px; | ||
| border-radius: 10px; | ||
| width: 100px; | ||
| color: #000; | ||
| background-color: #fff; | ||
| cursor: pointer; | ||
| transition: all 0.3s; | ||
| transition-timing-function: ease-in-out; | ||
| } | ||
| button:hover { | ||
| letter-spacing: 1px; | ||
| color: #fff; | ||
| background-color: #000; | ||
| border: 1px solid #fff; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice touch :)
style.css
Outdated
| @@ -0,0 +1,115 @@ | |||
| * { | |||
| padding: 0; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please convert the spaces to tabs on this file.
app.ts
Outdated
|
|
||
| // Loads all intial fields/data | ||
|
|
||
| window.onload = function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump
app.ts
Outdated
| const next = new Next(); // next class | ||
| const prev = new Prev(); // prev class | ||
| window.addEventListener("input", debounce(idJump, 500)); | ||
| window.addEventListener("resize", debounce(resizing, 500)); | ||
| getRecordCount() | ||
| .then(() => { | ||
| return getHeadings(); | ||
| }) | ||
| .then(() => { | ||
| return getTable(); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The classes and functions that you are using here should be defined before you use them.
| } else { | ||
| alert("ERROR"); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably also want to return in this else as the rest of your code doesn't really work if the content does not exist.
app.ts
Outdated
| } | ||
|
|
||
| // Table Content | ||
| function createTableContent(contentData: any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please specify the type of contentData. If you can use it int a for-loop then you at the very least know its an array.
app.ts
Outdated
| clearTimeout(timer); | ||
| timer = setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add this timer (with a different name) to the class, then you are less depended on the global variables.
app.ts
Outdated
| }; | ||
|
|
||
| if (this.prevButton) { | ||
| this.prevButton.addEventListener("click", prevDebounce(prev, 500)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about the debounce that I made on the Next class, should help you get rid of the prevCount.
app.ts
Outdated
| clearTimeout(timer); | ||
| timer = setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about the timer I made in the Next class
app.ts
Outdated
|
|
||
| // ID Jump | ||
| function idJump() { | ||
| const input: any = document.querySelector("input"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use any.
style.css
Outdated
| #content { | ||
| display: flex; | ||
| flex-direction: column; | ||
| height: calc(100vh - 15vh); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calc is bad, don't use calc
|
|
||
| // Table Content (Getting the table's data) | ||
| function getTable(): Promise<void> { | ||
| const content: HTMLElement | null = document.getElementById("content"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a rule about how to use document.getElementById in the Javascript Style Guide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry man, I just saw that, I'm removing that section from the style guide :P Had a discussion with cobus a while back, and we preferred the more pure route.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem!!
FritzOnFire
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small changes, but I think you are done.
app.ts
Outdated
| @@ -0,0 +1,286 @@ | |||
| let fromParameter = 0; | |||
| let recordCount: number; | |||
| const el = document.getElementById | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this.
| } | ||
|
|
||
| // Table Content | ||
| function appendTableContent(contentData: string | string[]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way your code is written it should definitely only be string[]
app.ts
Outdated
| }) | ||
| .then(handleErrors) | ||
| .then((response: Response) => response.json()) | ||
| .then((headingData: string | string[]) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way your code is written it should definitely only be string[]
app.ts
Outdated
| }) | ||
| .then(handleErrors) | ||
| .then((res: Response) => res.json()) | ||
| .then((contentData: string | string[]) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They way your code is written... neither of these are right. Based off what you get from the back end, should it not be a 2D array?
app.ts
Outdated
| return () => { | ||
| clearTimeout(this.nextTimer); | ||
| this.nextTimer = setTimeout(() => { | ||
| fn(); | ||
| }, delay); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should rather change this to not return a function, that way you don't have to add that weird () on line 189.
app.ts
Outdated
| // Previous | ||
| class Prev { | ||
| prevButton: HTMLElement | null; | ||
| prevTimer: number = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing ;
| const prevDebounce = (fn: () => void, delay: number) => { | ||
| return () => { | ||
| clearTimeout(this.prevTimer); | ||
| this.prevTimer = setTimeout(() => { | ||
| fn(); | ||
| }, delay); | ||
| }; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should rather change this to not return a function, that way you don't have to have that weird () on line 231.
app.ts
Outdated
| fromParameter = toParameter - getNoOfRows(); | ||
| } | ||
|
|
||
| nextDebounce(getTable, 500)() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing ;
app.ts
Outdated
| // Next | ||
| class Next { | ||
| nextButton: HTMLElement | null; | ||
| nextTimer: number = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing ;
app.ts
Outdated
| fromParameter = intOne; | ||
| } | ||
|
|
||
| prevDebounce(getTable, 500)() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing ;
Onboarding Javascript